using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace Coding4Fun.Phone.Controls
{
	public class RoundToggleButton : CheckBox
	{
		private const string string_0 = "OpacityImageBrush";
		private const string string_1 = "ContentBody";
		protected ImageBrush OpacityImageBrush;
		protected ContentControl ContentBody;
		public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(Orientation), typeof(RoundToggleButton), new PropertyMetadata(0));
		public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(RoundToggleButton), new PropertyMetadata(new PropertyChangedCallback(RoundToggleButton.smethod_0)));
		public Orientation Orientation
		{
			get
			{
				return (Orientation)base.GetValue(RoundToggleButton.OrientationProperty);
			}
			set
			{
				base.SetValue(RoundToggleButton.OrientationProperty, value);
			}
		}
		public ImageSource ImageSource
		{
			get
			{
				return (ImageSource)base.GetValue(RoundToggleButton.ImageSourceProperty);
			}
			set
			{
				base.SetValue(RoundToggleButton.ImageSourceProperty, value);
			}
		}
		public RoundToggleButton()
		{
			base.set_DefaultStyleKey(typeof(RoundToggleButton));
		}
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			this.OpacityImageBrush = (base.GetTemplateChild("OpacityImageBrush") as ImageBrush);
			this.ContentBody = (base.GetTemplateChild("ContentBody") as ContentControl);
			if (this.ImageSource == null)
			{
				this.ImageSource = new BitmapImage(new Uri("/Coding4Fun.Phone.Controls;component/Media/icons/appbar.check.rest.png", 0));
			}
			else
			{
				this.method_0(this.ImageSource);
			}
			if (this.ContentBody != null)
			{
				double num = -(this.ContentBody.get_FontSize() / 8.0);
				double num2 = -(this.ContentBody.get_FontSize() / 2.0) - num;
				this.ContentBody.set_Margin(new Thickness(0.0, num2, 0.0, num));
			}
		}
		private static void smethod_0(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			RoundToggleButton roundToggleButton = dependencyObject_0 as RoundToggleButton;
			if (roundToggleButton != null)
			{
				if (dependencyPropertyChangedEventArgs_0.get_NewValue() != dependencyPropertyChangedEventArgs_0.get_OldValue())
				{
					roundToggleButton.method_0(dependencyPropertyChangedEventArgs_0.get_NewValue() as ImageSource);
					return;
				}
			}
		}
		private void method_0(ImageSource imageSource_0)
		{
			if (this.OpacityImageBrush == null)
			{
				return;
			}
			this.OpacityImageBrush.set_ImageSource(imageSource_0);
		}
	}
}
